/**
 * 模拟API响应数据
 * 用于开发阶段，当后端API未就绪时使用
 */

// 模拟延迟
export const delay = (ms = 300) => {
  return new Promise(resolve => setTimeout(resolve, ms))
}

// 模拟成功响应
export const mockSuccess = async (data, message = '操作成功', ms = 300) => {
  await delay(ms)
  return {
    code: 200,
    message,
    data
  }
}

// 模拟失败响应
export const mockError = async (message = '操作失败', code = 500, ms = 300) => {
  await delay(ms)
  return {
    code,
    message,
    data: null
  }
}

// 模拟分页数据
export const mockPagination = (list, total, pageNum, pageSize) => {
  return {
    list,
    total,
    pageNum,
    pageSize
  }
}

// 学生仪表盘模拟数据
export const mockStudentDashboard = async () => {
  return mockSuccess({
    courseCount: 6,
    gradedCourseCount: 4,
    todayCourseCount: 2,
    todayCourses: [
      {
        time: '08:00-09:40',
        name: '高等数学',
        teacher: '张教授',
        location: '教学楼A-101',
        status: '已结束'
      },
      {
        time: '10:00-11:40',
        name: '大学英语',
        teacher: '李教授',
        location: '教学楼B-203',
        status: '进行中'
      },
      {
        time: '14:00-15:40',
        name: '计算机基础',
        teacher: '王教授',
        location: '实验楼C-305',
        status: '未开始'
      }
    ],
    notices: [
      {
        id: 1,
        title: '关于2023-2024学年第一学期期末考试安排的通知',
        date: '2023-12-10'
      },
      {
        id: 2,
        title: '关于寒假放假安排的通知',
        date: '2023-12-15'
      }
    ]
  })
}

// 学生信息模拟数据
export const mockStudentInfo = async () => {
  return mockSuccess({
    id: '2023001',
    name: '张三',
    gender: '男',
    age: 20,
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
    department: '计算机科学与技术学院',
    major: '软件工程',
    class: '软工2301班',
    enrollmentYear: '2023',
    email: 'zhangsan@example.com',
    phone: '13800138000'
  })
}

// 模拟课程列表数据
export const mockCourseList = async (params) => {
  const { pageNum = 1, pageSize = 10 } = params || {}
  
  const list = [
    {
      id: 1,
      courseCode: 'CS101',
      courseName: '计算机导论',
      credits: 3,
      courseType: '必修',
      moduleType: '专业基础',
      teacher: '王教授',
      timeLocation: '周一 1-2节 教学楼A-101',
      capacity: 60,
      selectedCount: 45,
      isSelected: true
    },
    {
      id: 2,
      courseCode: 'CS102',
      courseName: '数据结构',
      credits: 4,
      courseType: '必修',
      moduleType: '专业核心',
      teacher: '李教授',
      timeLocation: '周二 3-4节 教学楼B-203',
      capacity: 50,
      selectedCount: 48,
      isSelected: true
    },
    {
      id: 3,
      courseCode: 'CS103',
      courseName: '操作系统',
      credits: 3.5,
      courseType: '必修',
      moduleType: '专业核心',
      teacher: '张教授',
      timeLocation: '周三 5-6节 实验楼C-305',
      capacity: 55,
      selectedCount: 40,
      isSelected: false
    },
    {
      id: 4,
      courseCode: 'CS104',
      courseName: '计算机网络',
      credits: 3,
      courseType: '必修',
      moduleType: '专业核心',
      teacher: '刘教授',
      timeLocation: '周四 7-8节 教学楼A-201',
      capacity: 60,
      selectedCount: 55,
      isSelected: false
    },
    {
      id: 5,
      courseCode: 'CS105',
      courseName: '软件工程',
      credits: 4,
      courseType: '必修',
      moduleType: '专业核心',
      teacher: '陈教授',
      timeLocation: '周五 1-2节 教学楼B-303',
      capacity: 50,
      selectedCount: 48,
      isSelected: true
    }
  ]
  
  // 模拟分页
  const start = (pageNum - 1) * pageSize
  const end = start + pageSize
  const pageList = list.slice(start, end)
  
  return mockSuccess(mockPagination(pageList, list.length, pageNum, pageSize))
}

// 模拟待签到课程列表
export const mockPendingAttendance = async () => {
  return mockSuccess([
    {
      id: 1,
      name: '高等数学',
      teacher: '王教授',
      location: 'A101',
      time: '08:00-09:40',
      status: '进行中',
      signedIn: false
    },
    {
      id: 2,
      name: '大学英语',
      teacher: '李教授',
      location: 'B202',
      time: '10:00-11:40',
      status: '未开始',
      signedIn: false
    },
    {
      id: 3,
      name: '程序设计基础',
      teacher: '张教授',
      location: 'C303',
      time: '14:00-15:40',
      status: '未开始',
      signedIn: false
    },
    {
      id: 4,
      name: '数据结构',
      teacher: '刘教授',
      location: 'D404',
      time: '16:00-17:40',
      status: '未开始',
      signedIn: false
    }
  ])
}

// 模拟签到记录
export const mockAttendanceRecords = async (params) => {
  const { pageNum = 1, pageSize = 10 } = params || {}
  
  const list = [
    {
      id: 1,
      date: '2023-09-01',
      time: '08:00-09:40',
      courseName: '高等数学',
      teacher: '王教授',
      location: 'A101',
      status: '已签到',
      signInTime: '2023-09-01 07:55:23',
      remark: ''
    },
    {
      id: 2,
      date: '2023-09-01',
      time: '10:00-11:40',
      courseName: '大学英语',
      teacher: '李教授',
      location: 'B202',
      status: '迟到',
      signInTime: '2023-09-01 10:15:42',
      remark: '迟到15分钟'
    },
    {
      id: 3,
      date: '2023-09-02',
      time: '08:00-09:40',
      courseName: '高等数学',
      teacher: '王教授',
      location: 'A101',
      status: '已签到',
      signInTime: '2023-09-02 07:50:11',
      remark: ''
    },
    {
      id: 4,
      date: '2023-09-02',
      time: '14:00-15:40',
      courseName: '程序设计基础',
      teacher: '张教授',
      location: 'C303',
      status: '已签到',
      signInTime: '2023-09-02 13:55:37',
      remark: ''
    },
    {
      id: 5,
      date: '2023-09-03',
      time: '08:00-09:40',
      courseName: '高等数学',
      teacher: '王教授',
      location: 'A101',
      status: '请假',
      signInTime: '',
      remark: '病假'
    },
    {
      id: 6,
      date: '2023-09-03',
      time: '10:00-11:40',
      courseName: '大学英语',
      teacher: '李教授',
      location: 'B202',
      status: '已签到',
      signInTime: '2023-09-03 09:58:21',
      remark: ''
    },
    {
      id: 7,
      date: '2023-09-04',
      time: '14:00-15:40',
      courseName: '程序设计基础',
      teacher: '张教授',
      location: 'C303',
      status: '缺勤',
      signInTime: '',
      remark: '无故缺勤'
    },
    {
      id: 8,
      date: '2023-09-04',
      time: '16:00-17:40',
      courseName: '数据结构',
      teacher: '刘教授',
      location: 'D404',
      status: '已签到',
      signInTime: '2023-09-04 15:55:42',
      remark: ''
    }
  ]
  
  // 模拟分页
  const start = (pageNum - 1) * pageSize
  const end = start + pageSize
  const pageList = list.slice(start, end)
  
  return mockSuccess(mockPagination(pageList, list.length, pageNum, pageSize))
}

// 模拟考勤统计
export const mockAttendanceStatistics = async () => {
  return mockSuccess({
    total: 30,
    attended: 22,
    late: 3,
    leave: 2,
    absent: 3,
    attendanceRate: 73.3
  })
}

// 模拟课表数据
export const mockSchedule = async (params) => {
  return mockSuccess([
    {
      time: '第1-2节',
      monday: '高等数学\nA101\n王教授',
      tuesday: '大学英语\nB202\n李教授',
      wednesday: '',
      thursday: '计算机导论\nC303\n张教授',
      friday: '软件工程\nD404\n陈教授',
      saturday: '',
      sunday: ''
    },
    {
      time: '第3-4节',
      monday: '',
      tuesday: '数据结构\nB203\n李教授',
      wednesday: '操作系统\nC305\n张教授',
      thursday: '',
      friday: '计算机网络\nA201\n刘教授',
      saturday: '',
      sunday: ''
    },
    {
      time: '第5-6节',
      monday: '程序设计基础\nC303\n张教授',
      tuesday: '',
      wednesday: '高等数学\nA101\n王教授',
      thursday: '大学英语\nB202\n李教授',
      friday: '',
      saturday: '',
      sunday: ''
    },
    {
      time: '第7-8节',
      monday: '',
      tuesday: '',
      wednesday: '',
      thursday: '数据结构\nB203\n李教授',
      friday: '',
      saturday: '',
      sunday: ''
    }
  ])
}

// 模拟已选课程
export const mockSelectedCourses = async () => {
  return mockSuccess([
    {
      id: 1,
      courseCode: 'CS101',
      courseName: '计算机导论',
      credits: 3,
      courseType: '必修',
      teacher: '张教授',
      timeLocation: '周四 1-2节 教学楼C-303'
    },
    {
      id: 2,
      courseCode: 'CS102',
      courseName: '数据结构',
      credits: 4,
      courseType: '必修',
      teacher: '李教授',
      timeLocation: '周二/周四 3-4节 教学楼B-203'
    },
    {
      id: 5,
      courseCode: 'CS105',
      courseName: '软件工程',
      credits: 4,
      courseType: '必修',
      teacher: '陈教授',
      timeLocation: '周五 1-2节 教学楼B-303'
    },
    {
      id: 6,
      courseCode: 'MA101',
      courseName: '高等数学',
      credits: 5,
      courseType: '必修',
      teacher: '王教授',
      timeLocation: '周一/周三 1-2节 教学楼A-101'
    },
    {
      id: 7,
      courseCode: 'EN101',
      courseName: '大学英语',
      credits: 3,
      courseType: '必修',
      teacher: '李教授',
      timeLocation: '周二/周四 1-2节 教学楼B-202'
    },
    {
      id: 8,
      courseCode: 'CS103',
      courseName: '操作系统',
      credits: 3.5,
      courseType: '必修',
      teacher: '张教授',
      timeLocation: '周三 3-4节 实验楼C-305'
    }
  ])
}

// 模拟选课记录
export const mockSelectionRecords = async () => {
  return mockSuccess([
    {
      id: 1,
      timestamp: '2023-09-01 10:15:23',
      courseCode: 'CS101',
      courseName: '计算机导论',
      operation: '选课',
      status: '成功',
      remark: ''
    },
    {
      id: 2,
      timestamp: '2023-09-01 10:20:45',
      courseCode: 'CS102',
      courseName: '数据结构',
      operation: '选课',
      status: '成功',
      remark: ''
    },
    {
      id: 3,
      timestamp: '2023-09-01 10:25:12',
      courseCode: 'CS103',
      courseName: '操作系统',
      operation: '选课',
      status: '成功',
      remark: ''
    },
    {
      id: 4,
      timestamp: '2023-09-01 10:30:05',
      courseCode: 'CS103',
      courseName: '操作系统',
      operation: '退课',
      status: '成功',
      remark: ''
    },
    {
      id: 5,
      timestamp: '2023-09-01 10:35:18',
      courseCode: 'CS105',
      courseName: '软件工程',
      operation: '选课',
      status: '成功',
      remark: ''
    },
    {
      id: 6,
      timestamp: '2023-09-01 10:40:33',
      courseCode: 'MA101',
      courseName: '高等数学',
      operation: '选课',
      status: '成功',
      remark: ''
    },
    {
      id: 7,
      timestamp: '2023-09-01 10:45:22',
      courseCode: 'EN101',
      courseName: '大学英语',
      operation: '选课',
      status: '成功',
      remark: ''
    },
    {
      id: 8,
      timestamp: '2023-09-01 10:50:41',
      courseCode: 'CS103',
      courseName: '操作系统',
      operation: '选课',
      status: '成功',
      remark: ''
    }
  ])
}

// 模拟作业列表
export const mockHomeworkList = async (params) => {
  const { pageNum = 1, pageSize = 10 } = params || {}
  
  const list = [
    {
      id: 1,
      title: '高等数学第一章习题',
      courseName: '高等数学',
      teacher: '王教授',
      publishTime: '2023-09-01 08:30:00',
      deadline: '2023-09-08 23:59:59',
      status: '已提交',
      score: 92
    },
    {
      id: 2,
      title: '英语听力练习',
      courseName: '大学英语',
      teacher: '李教授',
      publishTime: '2023-09-02 10:15:00',
      deadline: '2023-09-09 23:59:59',
      status: '已提交',
      score: 85
    },
    {
      id: 3,
      title: 'C语言编程作业',
      courseName: '程序设计基础',
      teacher: '张教授',
      publishTime: '2023-09-03 14:30:00',
      deadline: '2023-09-10 23:59:59',
      status: '未提交',
      score: null
    },
    {
      id: 4,
      title: '数据结构实验一',
      courseName: '数据结构',
      teacher: '李教授',
      publishTime: '2023-09-04 09:00:00',
      deadline: '2023-09-11 23:59:59',
      status: '进行中',
      score: null
    },
    {
      id: 5,
      title: '高等数学第二章习题',
      courseName: '高等数学',
      teacher: '王教授',
      publishTime: '2023-09-08 08:30:00',
      deadline: '2023-09-15 23:59:59',
      status: '未开始',
      score: null
    }
  ]
  
  // 模拟分页
  const start = (pageNum - 1) * pageSize
  const end = start + pageSize
  const pageList = list.slice(start, end)
  
  return mockSuccess(mockPagination(pageList, list.length, pageNum, pageSize))
}

// 模拟作业课程列表
export const mockHomeworkCourses = async () => {
  return mockSuccess([
    {
      id: 1,
      name: '高等数学',
      teacher: '王教授',
      icon: 'DataAnalysis',
      color: '#409EFF',
      stats: {
        pending: 2,
        submitted: 1,
        graded: 3
      }
    },
    {
      id: 2,
      name: '大学英语',
      teacher: '李教授',
      icon: 'Reading',
      color: '#67C23A',
      stats: {
        pending: 1,
        submitted: 0,
        graded: 4
      }
    },
    {
      id: 3,
      name: '程序设计基础',
      teacher: '张教授',
      icon: 'Document',
      color: '#E6A23C',
      stats: {
        pending: 0,
        submitted: 2,
        graded: 2
      }
    },
    {
      id: 4,
      name: '数据结构',
      teacher: '刘教授',
      icon: 'Connection',
      color: '#F56C6C',
      stats: {
        pending: 1,
        submitted: 1,
        graded: 1
      }
    },
    {
      id: 5,
      name: '计算机网络',
      teacher: '陈教授',
      icon: 'Promotion',
      color: '#9B59B6',
      stats: {
        pending: 0,
        submitted: 0,
        graded: 3
      }
    },
    {
      id: 6,
      name: '软件工程',
      teacher: '赵教授',
      icon: 'Collection',
      color: '#3498DB',
      stats: {
        pending: 1,
        submitted: 0,
        graded: 0
      }
    }
  ])
}

// 模拟按课程的作业列表
export const mockHomeworkListByCourse = async (params) => {
  const { courseId } = params || {}
  
  // 高等数学课程作业
  if (courseId == 1) {
    return mockSuccess([
      {
        id: 1,
        courseId: 1,
        title: '第一章习题',
        releaseTime: '2023-09-01 10:00:00',
        deadline: '2023-09-10 23:59:59',
        status: '已批改',
        submitTime: '2023-09-08 15:30:45',
        gradeTime: '2023-09-12 14:20:30',
        score: 85,
        description: '完成教材第一章的习题1-10'
      },
      {
        id: 2,
        courseId: 1,
        title: '第二章习题',
        releaseTime: '2023-09-10 10:00:00',
        deadline: '2023-09-20 23:59:59',
        status: '已批改',
        submitTime: '2023-09-18 16:42:21',
        gradeTime: '2023-09-22 11:15:40',
        score: 92,
        description: '完成教材第二章的习题1-15'
      },
      {
        id: 3,
        courseId: 1,
        title: '第三章习题',
        releaseTime: '2023-09-20 10:00:00',
        deadline: '2023-09-30 23:59:59',
        status: '已批改',
        submitTime: '2023-09-28 22:10:05',
        gradeTime: '2023-10-02 09:30:15',
        score: 78,
        description: '完成教材第三章的习题1-12'
      },
      {
        id: 4,
        courseId: 1,
        title: '第四章习题',
        releaseTime: '2023-10-01 10:00:00',
        deadline: '2023-10-10 23:59:59',
        status: '已提交',
        submitTime: '2023-10-05 18:25:33',
        gradeTime: null,
        score: null,
        description: '完成教材第四章的习题1-20'
      },
      {
        id: 5,
        courseId: 1,
        title: '第五章习题',
        releaseTime: '2023-10-10 10:00:00',
        deadline: '2023-10-20 23:59:59',
        status: '未提交',
        submitTime: null,
        gradeTime: null,
        score: null,
        description: '完成教材第五章的习题1-18'
      },
      {
        id: 6,
        courseId: 1,
        title: '期中考试复习题',
        releaseTime: '2023-10-15 10:00:00',
        deadline: '2023-10-25 23:59:59',
        status: '未提交',
        submitTime: null,
        gradeTime: null,
        score: null,
        description: '完成期中考试复习题，范围包括第一章到第五章'
      }
    ])
  }
  
  // 数据结构课程作业
  if (courseId == 4) {
    return mockSuccess([
      {
        id: 7,
        courseId: 4,
        title: '线性表编程作业',
        releaseTime: '2023-09-05 14:00:00',
        deadline: '2023-09-15 23:59:59',
        status: '已批改',
        submitTime: '2023-09-14 23:30:10',
        gradeTime: '2023-09-17 10:20:30',
        score: 90,
        description: '实现单链表的基本操作，包括插入、删除、查找等'
      },
      {
        id: 8,
        courseId: 4,
        title: '栈与队列编程作业',
        releaseTime: '2023-09-20 14:00:00',
        deadline: '2023-09-30 23:59:59',
        status: '已提交',
        submitTime: '2023-09-29 22:15:40',
        gradeTime: null,
        score: null,
        description: '实现栈和队列的基本操作，并用栈解决括号匹配问题'
      },
      {
        id: 9,
        courseId: 4,
        title: '树与二叉树编程作业',
        releaseTime: '2023-10-05 14:00:00',
        deadline: '2023-10-15 23:59:59',
        status: '未提交',
        submitTime: null,
        gradeTime: null,
        score: null,
        description: '实现二叉树的创建、遍历和基本操作'
      }
    ])
  }
  
  // 其他课程返回空数组
  return mockSuccess([])
}

// 模拟成绩列表
export const mockGradesList = async (params) => {
  const { semester } = params || {}
  
  // 不同学期的成绩数据
  const gradesData = {
    '2022-2023-2': {
      grades: [
        {
          courseCode: 'CS3017',
          courseName: '数据库系统',
          credit: 4,
          courseType: '专业必修课',
          examType: '考试',
          grade: 87,
          gradePoint: 3.7,
          teacher: '张三',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 90 },
            { name: '实验成绩', percentage: 30, score: 85 },
            { name: '期末考试', percentage: 50, score: 87 }
          ],
          teacherComment: '对数据库基本概念理解透彻，但SQL查询优化能力还需加强。'
        },
        {
          courseCode: 'CS3021',
          courseName: '操作系统',
          credit: 4,
          courseType: '专业必修课',
          examType: '考试',
          grade: 92,
          gradePoint: 4.0,
          teacher: '李四',
          gradeComponents: [
            { name: '平时成绩', percentage: 10, score: 95 },
            { name: '课程设计', percentage: 40, score: 94 },
            { name: '期末考试', percentage: 50, score: 90 }
          ],
          teacherComment: '对操作系统原理理解深入，实验动手能力强，是一个很有潜力的学生。'
        },
        {
          courseCode: 'CS3026',
          courseName: '计算机网络',
          credit: 3,
          courseType: '专业必修课',
          examType: '考试',
          grade: 78,
          gradePoint: 3.0,
          teacher: '王五',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 75 },
            { name: '实验报告', percentage: 20, score: 80 },
            { name: '期末考试', percentage: 60, score: 78 }
          ],
          teacherComment: ''
        },
        {
          courseCode: 'MA2002',
          courseName: '概率论与数理统计',
          credit: 3,
          courseType: '公共必修课',
          examType: '考试',
          grade: 55,
          gradePoint: 1.0,
          teacher: '赵六',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 60 },
            { name: '作业', percentage: 20, score: 55 },
            { name: '期末考试', percentage: 60, score: 53 }
          ],
          teacherComment: '基础较为薄弱，建议加强概率论基本定理的学习，并多做习题。'
        },
        {
          courseCode: 'EN2008',
          courseName: '大学英语（4）',
          credit: 2,
          courseType: '公共必修课',
          examType: '考试',
          grade: 85,
          gradePoint: 3.5,
          teacher: '钱七',
          gradeComponents: [
            { name: '平时成绩', percentage: 30, score: 88 },
            { name: '口语测试', percentage: 20, score: 80 },
            { name: '期末考试', percentage: 50, score: 85 }
          ],
          teacherComment: ''
        }
      ],
      stats: {
        averageScore: 79.4,
        passedCourses: 4,
        totalCourses: 5,
        earnedCredits: 13,
        totalCredits: 16
      }
    },
    '2022-2023-1': {
      grades: [
        {
          courseCode: 'CS3012',
          courseName: '算法设计与分析',
          credit: 3,
          courseType: '专业必修课',
          examType: '考试',
          grade: 88,
          gradePoint: 3.7,
          teacher: '张三',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 90 },
            { name: '编程实验', percentage: 30, score: 86 },
            { name: '期末考试', percentage: 50, score: 88 }
          ],
          teacherComment: ''
        },
        {
          courseCode: 'CS3015',
          courseName: '编译原理',
          credit: 4,
          courseType: '专业必修课',
          examType: '考试',
          grade: 81,
          gradePoint: 3.3,
          teacher: '李四',
          gradeComponents: [
            { name: '平时成绩', percentage: 10, score: 85 },
            { name: '编译器设计', percentage: 40, score: 80 },
            { name: '期末考试', percentage: 50, score: 80 }
          ],
          teacherComment: '词法分析和语法分析掌握得较好，代码生成部分有待加强。'
        },
        {
          courseCode: 'CS3022',
          courseName: '计算机组成原理',
          credit: 4,
          courseType: '专业必修课',
          examType: '考试',
          grade: 76,
          gradePoint: 2.7,
          teacher: '王五',
          gradeComponents: [
            { name: '平时成绩', percentage: 10, score: 70 },
            { name: '实验报告', percentage: 30, score: 75 },
            { name: '期末考试', percentage: 60, score: 78 }
          ],
          teacherComment: ''
        },
        {
          courseCode: 'MA2001',
          courseName: '线性代数',
          credit: 3,
          courseType: '公共必修课',
          examType: '考试',
          grade: 92,
          gradePoint: 4.0,
          teacher: '赵六',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 95 },
            { name: '作业', percentage: 20, score: 90 },
            { name: '期末考试', percentage: 60, score: 92 }
          ],
          teacherComment: '数学思维清晰，矩阵理论掌握得非常好。'
        }
      ],
      stats: {
        averageScore: 84.2,
        passedCourses: 4,
        totalCourses: 4,
        earnedCredits: 14,
        totalCredits: 14
      }
    },
    '2021-2022-2': {
      grades: [
        {
          courseCode: 'CS2035',
          courseName: '数据结构',
          credit: 4,
          courseType: '专业必修课',
          examType: '考试',
          grade: 90,
          gradePoint: 4.0,
          teacher: '张三',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 92 },
            { name: '编程实验', percentage: 30, score: 89 },
            { name: '期末考试', percentage: 50, score: 90 }
          ],
          teacherComment: '数据结构基础扎实，算法实现能力强。'
        },
        {
          courseCode: 'CS2042',
          courseName: '面向对象程序设计',
          credit: 3,
          courseType: '专业必修课',
          examType: '考试',
          grade: 45,
          gradePoint: 0,
          teacher: '李四',
          gradeComponents: [
            { name: '平时成绩', percentage: 20, score: 60 },
            { name: '课程设计', percentage: 30, score: 40 },
            { name: '期末考试', percentage: 50, score: 42 }
          ],
          teacherComment: '对面向对象概念理解不够深入，需要加强实践。'
        }
      ],
      stats: {
        averageScore: 67.5,
        passedCourses: 1,
        totalCourses: 2,
        earnedCredits: 4,
        totalCredits: 7
      }
    }
  }
  
  // 如果指定了学期，返回该学期的数据
  if (semester && gradesData[semester]) {
    return mockSuccess(gradesData[semester])
  }
  
  // 默认返回最新学期的数据
  return mockSuccess(gradesData['2022-2023-2'])
}

// 模拟学期列表
export const mockSemesters = async () => {
  return mockSuccess([
    { value: '2023-2024-1', label: '2023-2024学年 第一学期' },
    { value: '2022-2023-2', label: '2022-2023学年 第二学期' },
    { value: '2022-2023-1', label: '2022-2023学年 第一学期' },
    { value: '2021-2022-2', label: '2021-2022学年 第二学期' },
    { value: '2021-2022-1', label: '2021-2022学年 第一学期' }
  ])
}

// 模拟当前学期
export const mockCurrentSemester = async () => {
  return mockSuccess({
    value: '2023-2024-1',
    label: '2023-2024学年 第一学期',
    startDate: '2023-09-01',
    endDate: '2024-01-15',
    currentWeek: 10
  })
}

// 模拟字典数据
export const mockDictData = async (dictType) => {
  // 根据字典类型返回不同的数据
  if (dictType === 'course_type') {
    return mockSuccess([
      { value: '必修', label: '必修' },
      { value: '选修', label: '选修' },
      { value: '通识', label: '通识' },
      { value: '实验', label: '实验' }
    ])
  } else if (dictType === 'module_type') {
    return mockSuccess([
      { value: '通识教育', label: '通识教育' },
      { value: '专业基础', label: '专业基础' },
      { value: '专业核心', label: '专业核心' },
      { value: '专业选修', label: '专业选修' },
      { value: '公共必修', label: '公共必修' }
    ])
  } else if (dictType === 'attendance_status') {
    return mockSuccess([
      { value: '已签到', label: '已签到' },
      { value: '缺勤', label: '缺勤' },
      { value: '请假', label: '请假' },
      { value: '迟到', label: '迟到' }
    ])
  }
  
  return mockSuccess([])
}

// 模拟资源列表
export const mockResourceList = async (params) => {
  const { pageNum = 1, pageSize = 10, keyword = '', category = '', type = '' } = params || {}
  
  // 模拟资源数据
  const resources = [
    {
      id: 1,
      name: '高等数学教材（第三版）.pdf',
      category: '教材电子版',
      size: '15.2MB',
      type: 'pdf',
      uploadTime: '2023-02-15 10:23:45',
      downloadCount: 245,
      canDownload: true,
      description: '《高等数学》第三版完整教材，包含微积分、线性代数等内容。'
    },
    {
      id: 2,
      name: '数据结构与算法分析课件.ppt',
      category: '课件',
      size: '8.5MB',
      type: 'ppt',
      uploadTime: '2023-03-10 14:30:22',
      downloadCount: 187,
      canDownload: true,
      description: '数据结构与算法分析课程PPT，包含排序算法、树结构等内容。'
    },
    {
      id: 3,
      name: '计算机组成原理实验指导书.docx',
      category: '实验指导',
      size: '3.7MB',
      type: 'doc',
      uploadTime: '2023-04-05 09:12:38',
      downloadCount: 156,
      canDownload: true,
      description: '计算机组成原理课程实验指导文档，包含5个实验内容及要求。'
    },
    {
      id: 4,
      name: '操作系统课程设计案例.zip',
      category: '教学资料',
      size: '42MB',
      type: 'zip',
      uploadTime: '2023-03-22 16:45:10',
      downloadCount: 98,
      canDownload: true,
      description: '操作系统课程设计参考案例，包含源代码和说明文档。'
    },
    {
      id: 5,
      name: '数据库系统概念（英文版）.pdf',
      category: '参考书目',
      size: '28.3MB',
      type: 'pdf',
      uploadTime: '2023-01-18 11:05:32',
      downloadCount: 76,
      canDownload: false,
      description: '《Database System Concepts》原版教材，仅供教师参考。'
    },
    {
      id: 6,
      name: 'Python编程入门视频教程.mp4',
      category: '教学资料',
      size: '256MB',
      type: 'video',
      uploadTime: '2023-05-02 13:28:56',
      downloadCount: 132,
      canDownload: true,
      description: 'Python编程基础视频教程，适合零基础学习。'
    },
    {
      id: 7,
      name: '数字电路原理图集.png',
      category: '教学资料',
      size: '5.6MB',
      type: 'image',
      uploadTime: '2023-04-12 10:18:43',
      downloadCount: 89,
      canDownload: true,
      description: '数字电路基本原理图及示例电路图集。'
    },
    {
      id: 8,
      name: '学术论文写作指南.pdf',
      category: '教学资料',
      size: '2.1MB',
      type: 'pdf',
      uploadTime: '2023-03-28 15:40:27',
      downloadCount: 201,
      canDownload: true,
      description: '学术论文写作规范与技巧指南，包含格式要求和案例分析。'
    },
    {
      id: 9,
      name: '计算机网络实验指导.pdf',
      category: '实验指导',
      size: '6.8MB',
      type: 'pdf',
      uploadTime: '2023-04-18 09:30:15',
      downloadCount: 112,
      canDownload: true,
      description: '计算机网络课程实验指导，包含网络配置和协议分析实验。'
    },
    {
      id: 10,
      name: '软件工程案例分析.ppt',
      category: '课件',
      size: '12.3MB',
      type: 'ppt',
      uploadTime: '2023-03-15 11:25:40',
      downloadCount: 78,
      canDownload: true,
      description: '软件工程经典案例分析，包含需求分析、设计模式等内容。'
    },
    {
      id: 11,
      name: '人工智能导论教材.pdf',
      category: '教材电子版',
      size: '18.7MB',
      type: 'pdf',
      uploadTime: '2023-02-20 14:15:30',
      downloadCount: 165,
      canDownload: true,
      description: '人工智能导论课程教材，包含机器学习、深度学习基础知识。'
    },
    {
      id: 12,
      name: '编译原理课程笔记.docx',
      category: '教学资料',
      size: '2.9MB',
      type: 'doc',
      uploadTime: '2023-04-08 16:20:15',
      downloadCount: 95,
      canDownload: true,
      description: '编译原理课程笔记，包含词法分析、语法分析等内容。'
    }
  ]
  
  // 根据关键字、分类和类型过滤
  let filteredResources = [...resources]
  
  if (keyword) {
    const lowerKeyword = keyword.toLowerCase()
    filteredResources = filteredResources.filter(item => 
      item.name.toLowerCase().includes(lowerKeyword)
    )
  }
  
  if (category) {
    filteredResources = filteredResources.filter(item => 
      item.category === category
    )
  }
  
  if (type) {
    filteredResources = filteredResources.filter(item => 
      item.type === type
    )
  }
  
  // 分页处理
  const total = filteredResources.length
  const start = (pageNum - 1) * pageSize
  const end = start + pageSize
  const list = filteredResources.slice(start, end)
  
  return mockSuccess({
    list,
    total,
    pageNum,
    pageSize
  })
}

// 模拟下载历史
export const mockDownloadHistory = async () => {
  return mockSuccess([
    {
      id: 1,
      fileName: '高等数学教材（第三版）.pdf',
      fileType: 'PDF',
      fileSize: '15.2MB',
      downloadTime: '2023-05-10 15:23:45',
      status: '成功',
      savePath: 'D:\\Downloads\\学习资料\\高等数学教材（第三版）.pdf'
    },
    {
      id: 2,
      fileName: '数据结构与算法分析课件.ppt',
      fileType: 'PPT',
      fileSize: '8.5MB',
      downloadTime: '2023-05-08 09:12:33',
      status: '成功',
      savePath: 'D:\\Downloads\\课件\\数据结构与算法分析课件.ppt'
    },
    {
      id: 3,
      fileName: '操作系统课程设计案例.zip',
      fileType: 'ZIP',
      fileSize: '42MB',
      downloadTime: '2023-05-05 14:30:22',
      status: '失败',
      savePath: '未完成'
    },
    {
      id: 4,
      fileName: 'Python编程入门视频教程.mp4',
      fileType: 'MP4',
      fileSize: '256MB',
      downloadTime: '2023-04-28 11:45:18',
      status: '成功',
      savePath: 'D:\\Downloads\\视频教程\\Python编程入门视频教程.mp4'
    }
  ])
}

// 模拟学分/成绩详情
export const mockCredits = async (params) => {
  // 可根据params.year等筛选
  return mockSuccess({
    creditStats: {
      earnedCredits: 120,
      requiredCredits: 155,
      remainingCredits: 35,
      creditProgress: 77.4,
      gpa: 3.65,
      totalCourses: 40
    },
    creditCategories: [
      { name: '公共必修课', earned: 32, required: 40, description: '包括数学、英语、物理等公共基础课程' },
      { name: '专业必修课', earned: 60, required: 70, description: '包括专业核心课程和实践环节' },
      { name: '专业选修课', earned: 18, required: 30, description: '专业方向选修课程，需至少修读30学分' },
      { name: '通识选修课', earned: 10, required: 15, description: '人文社科类、艺术类、创新创业类通识课程' }
    ],
    creditRecords: [
      { semester: '2022-2023学年第二学期', courseCode: 'CS3017', courseName: '数据库系统', category: '专业必修课', credit: 4, grade: 87, status: '已通过' },
      { semester: '2022-2023学年第二学期', courseCode: 'CS3021', courseName: '操作系统', category: '专业必修课', credit: 4, grade: 92, status: '已通过' },
      { semester: '2022-2023学年第二学期', courseCode: 'CS3026', courseName: '计算机网络', category: '专业必修课', credit: 3, grade: 78, status: '已通过' },
      { semester: '2022-2023学年第二学期', courseCode: 'MA2002', courseName: '概率论与数理统计', category: '公共必修课', credit: 3, grade: 55, status: '未通过' },
      { semester: '2022-2023学年第一学期', courseCode: 'CS3012', courseName: '算法设计与分析', category: '专业必修课', credit: 3, grade: 88, status: '已通过' },
      { semester: '2022-2023学年第一学期', courseCode: 'CS3015', courseName: '编译原理', category: '专业必修课', credit: 4, grade: 81, status: '已通过' },
      { semester: '2021-2022学年第二学期', courseCode: 'CS2035', courseName: '数据结构', category: '专业必修课', credit: 4, grade: 90, status: '已通过' },
      { semester: '2021-2022学年第二学期', courseCode: 'ART1002', courseName: '艺术鉴赏', category: '通识选修课', credit: 2, grade: 85, status: '已通过' },
      { semester: '2021-2022学年第一学期', courseCode: 'CS2022', courseName: '离散数学', category: '专业必修课', credit: 3, grade: 78, status: '已通过' },
      { semester: '2021-2022学年第一学期', courseCode: 'ENG2003', courseName: '高级英语写作', category: '公共必修课', credit: 2, grade: 82, status: '已通过' }
    ]
  })
}

// 模拟评教课程列表
export const mockEvaluationList = async (params) => {
  return mockSuccess({
    pendingCourses: [
      { id: 1, courseCode: 'CS3017', courseName: '数据库系统', teacher: '张三', semester: '2022-2023学年第二学期', endDate: '2023-06-20', deadline: '2023-07-05' },
      { id: 2, courseCode: 'CS3021', courseName: '操作系统', teacher: '李四', semester: '2022-2023学年第二学期', endDate: '2023-06-18', deadline: '2023-07-05' },
      { id: 3, courseCode: 'CS3026', courseName: '计算机网络', teacher: '王五', semester: '2022-2023学年第二学期', endDate: '2023-06-22', deadline: '2023-07-05' }
    ],
    completedCourses: [
      { id: 4, courseCode: 'CS3012', courseName: '算法设计与分析', teacher: '张三', semester: '2022-2023学年第一学期', evaluationDate: '2023-01-10', overallRating: 4, ratings: { contentRating: 4, designRating: 5, materialRating: 4, methodRating: 4, interactionRating: 3, responseRating: 5, knowledgeRating: 4, skillRating: 4 }, feedback: { strengths: '算法讲解清晰，实例丰富，课后练习难度适中，能够很好地帮助理解算法思想。', suggestions: '希望能增加一些实际工程中的算法应用案例，加强理论与实践的结合。' } },
      { id: 5, courseCode: 'CS3015', courseName: '编译原理', teacher: '李四', semester: '2022-2023学年第一学期', evaluationDate: '2023-01-08', overallRating: 5, ratings: { contentRating: 5, designRating: 5, materialRating: 4, methodRating: 5, interactionRating: 5, responseRating: 5, knowledgeRating: 5, skillRating: 5 }, feedback: { strengths: '老师教学经验丰富，将复杂的编译原理讲解得浅显易懂，课程项目设计合理，能够全面检验学习成果。', suggestions: '建议增加编译器前沿技术的介绍，如JIT编译等内容。' } }
    ]
  })
}

// 模拟评教详情
export const mockEvaluationDetail = async (id) => {
  // 这里只返回一条已评价课程的详细信息
  return mockSuccess({
    id,
    courseCode: 'CS3012',
    courseName: '算法设计与分析',
    teacher: '张三',
    semester: '2022-2023学年第一学期',
    evaluationDate: '2023-01-10',
    overallRating: 4,
    ratings: {
      contentRating: 4,
      designRating: 5,
      materialRating: 4,
      methodRating: 4,
      interactionRating: 3,
      responseRating: 5,
      knowledgeRating: 4,
      skillRating: 4
    },
    feedback: {
      strengths: '算法讲解清晰，实例丰富，课后练习难度适中，能够很好地帮助理解算法思想。',
      suggestions: '希望能增加一些实际工程中的算法应用案例，加强理论与实践的结合。'
    }
  })
}

// 模拟请假记录
export const mockLeaveList = async (params) => {
  return mockSuccess([
    {
      id: 'L202305100001',
      type: '事假',
      startTime: '2023-05-10 14:00',
      endTime: '2023-05-12 14:00',
      duration: '48小时',
      reason: '参加亲友婚礼',
      status: '审批中',
      approvalLog: [
        { content: '提交申请', timestamp: '2023-05-10 09:15:00', type: 'success', color: '#0bbd87' },
        { content: '辅导员王老师接收申请', timestamp: '2023-05-10 10:30:00', type: 'primary', color: '#409EFF' }
      ]
    },
    {
      id: 'L202304250002',
      type: '病假',
      startTime: '2023-04-25 08:00',
      endTime: '2023-04-27 18:00',
      duration: '58小时',
      reason: '感冒发烧，需要休息治疗',
      status: '已批准',
      approvalLog: [
        { content: '提交申请', timestamp: '2023-04-24 20:15:00', type: 'success', color: '#0bbd87' },
        { content: '辅导员王老师审批通过', timestamp: '2023-04-24 21:30:00', type: 'success', color: '#0bbd87' },
        { content: '院系李主任审批通过', timestamp: '2023-04-25 08:45:00', type: 'success', color: '#0bbd87' },
        { content: '生成电子签章请假单', timestamp: '2023-04-25 08:50:00', type: 'success', color: '#0bbd87' }
      ]
    },
    {
      id: 'L202303150003',
      type: '事假',
      startTime: '2023-03-15 14:00',
      endTime: '2023-03-15 18:00',
      duration: '4小时',
      reason: '办理银行卡业务',
      status: '已驳回',
      approvalLog: [
        { content: '提交申请', timestamp: '2023-03-14 16:20:00', type: 'success', color: '#0bbd87' },
        { content: '辅导员王老师驳回，原因：理由不充分，建议课后办理', timestamp: '2023-03-14 17:45:00', type: 'danger', color: '#F56C6C' }
      ]
    }
  ])
}

// 模拟推荐课程列表
export const mockRecommendedCourses = async (params) => {
  return mockSuccess([
    {
      id: 1,
      code: 'CS3017',
      name: '数据库系统',
      teacher: '张三',
      credit: 4,
      semester: '2023-2024学年第一学期',
      type: 'plan',
      category: 'required',
      matchScore: 95,
      description: '本课程介绍数据库系统的基本概念、原理和设计方法，包括关系模型、SQL语言、数据库设计等内容。',
      tags: ['必修课', '实验课', '数据管理'],
      reasons: [
        '必修课程，计算机专业核心课程',
        '符合您的学习计划进度',
        '与您已修读的数据结构课程内容相关'
      ],
      time: '周一 1-2节，周三 3-4节',
      location: '教学楼A-301'
    },
    {
      id: 2,
      code: 'CS3021',
      name: '操作系统',
      teacher: '李四',
      credit: 4,
      semester: '2023-2024学年第一学期',
      type: 'plan',
      category: 'required',
      matchScore: 92,
      description: '本课程介绍操作系统的基本概念、原理和实现方法，包括进程管理、内存管理、文件系统等内容。',
      tags: ['必修课', '理论课', '系统开发'],
      reasons: [
        '必修课程，计算机专业核心课程',
        '符合您的学习计划进度',
        '您在计算机组成原理课程中表现优秀'
      ],
      time: '周二 5-6节，周四 1-2节',
      location: '教学楼B-201'
    },
    {
      id: 3,
      code: 'CS3026',
      name: '计算机网络',
      teacher: '王五',
      credit: 3,
      semester: '2023-2024学年第一学期',
      type: 'plan',
      category: 'required',
      matchScore: 90,
      description: '本课程介绍计算机网络的基本概念、协议和应用，包括TCP/IP协议族、网络应用开发等内容。',
      tags: ['必修课', '实验课', '网络通信'],
      reasons: [
        '必修课程，计算机专业核心课程',
        '符合您的学习计划进度',
        '为后续分布式系统、云计算等课程打基础'
      ],
      time: '周一 5-6节，周三 7-8节',
      location: '教学楼C-102'
    },
    {
      id: 4,
      code: 'CS4002',
      name: '人工智能导论',
      teacher: '赵六',
      credit: 3,
      semester: '2023-2024学年第一学期',
      type: 'interest',
      category: 'elective',
      matchScore: 88,
      description: '本课程介绍人工智能的基本概念、原理和应用，包括搜索算法、知识表示、机器学习等内容。',
      tags: ['选修课', '理论课', 'AI', '前沿技术'],
      reasons: [
        '符合您的兴趣标签：AI、机器学习',
        '您在数学课程中表现优秀，适合学习AI',
        '当前就业市场对AI人才需求旺盛'
      ],
      time: '周二 3-4节，周四 5-6节',
      location: '教学楼A-501'
    },
    {
      id: 5,
      code: 'SE3008',
      name: '软件工程',
      teacher: '钱七',
      credit: 3,
      semester: '2023-2024学年第一学期',
      type: 'career',
      category: 'required',
      matchScore: 85,
      description: '本课程介绍软件开发的工程化方法，包括需求分析、系统设计、编码实现、测试验证等内容。',
      tags: ['必修课', '实践课', '项目管理'],
      reasons: [
        '符合您的职业规划：软件开发工程师',
        '提升项目实践和团队协作能力',
        '企业招聘普遍要求软件工程知识'
      ],
      time: '周五 1-4节',
      location: '教学楼B-301'
    }
  ])
}

// 模拟推荐课程详情
export const mockRecommendedCourseDetail = async (id) => {
  // 这里只返回一条课程的详细信息
  return mockSuccess({
    id,
    code: 'CS3017',
    name: '数据库系统',
    teacher: '张三',
    credit: 4,
    semester: '2023-2024学年第一学期',
    type: 'plan',
    category: 'required',
    matchScore: 95,
    description: '本课程介绍数据库系统的基本概念、原理和设计方法，包括关系模型、SQL语言、数据库设计等内容。',
    tags: ['必修课', '实验课', '数据管理'],
    reasons: [
      '必修课程，计算机专业核心课程',
      '符合您的学习计划进度',
      '与您已修读的数据结构课程内容相关'
    ],
    time: '周一 1-2节，周三 3-4节',
    location: '教学楼A-301'
  })
}

// 导出所有模拟数据函数
export default {
  mockSuccess,
  mockError,
  mockPagination,
  mockStudentDashboard,
  mockStudentInfo,
  mockCourseList,
  mockPendingAttendance,
  mockAttendanceRecords,
  mockAttendanceStatistics,
  mockSchedule,
  mockSelectedCourses,
  mockSelectionRecords,
  mockHomeworkList,
  mockHomeworkCourses,
  mockHomeworkListByCourse,
  mockGradesList,
  mockSemesters,
  mockCurrentSemester,
  mockDictData,
  mockResourceList,
  mockDownloadHistory,
  mockCredits,
  mockEvaluationList,
  mockEvaluationDetail,
  mockLeaveList,
  mockRecommendedCourses,
  mockRecommendedCourseDetail
} 